package com.smiletrain.activities.base;

import com.smiletrain.R;
import com.smiletrain.activities.WellcomeActivity;
import com.smiletrain.base.Caso;
import com.smiletrain.util.AdminActivity;
import com.smiletrain.util.AdminCasos;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Window;
import android.widget.ImageView;

public abstract class AbstractActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		
		if(caso == null){
			caso = AdminCasos.instance.getCasoActual();
			if(caso == null){
				Intent intent = new Intent(this, WellcomeActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
				finish();
				return;
			}
		}
        
	}
	
	public void setFootLayout() {
		
		ImageView atras = (ImageView) findViewById(R.id.bAtras);
        atras.setOnClickListener(new AdminActivity.BackOnClickListener(this));
        
        ImageView home = (ImageView) findViewById(R.id.imageViewX);
        home.setOnClickListener(new AdminActivity.HomeOnClickListener(this));
        
	}
	
	public abstract void updateCaso();
	
	protected Caso caso = AdminCasos.instance.getCasoActual();
	
}
